#include <bits/stdc++.h>
using namespace std;
const int N = 10;

int f[N][N];
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

int main()
{
	int n; cin >> n;
	int cnt = 1, pos = 0;
	int x = 1, y = 1;
	while(cnt <= n * n)
	{
		f[x][y] = cnt ++;
		int px = x + dx[pos], py = y + dy[pos];
		if(px < 1 || px > n || py < 1 || py > n || f[px][py] != 0)
		{
			pos ++;
			pos %= 4;
			px = x + dx[pos], py = y + dy[pos];
		}
		x = px, y = py;
	}
	for(int i = 1;i <= n;i ++)
	{
		for(int j = 1;j <= n;j ++) printf("%3d", f[i][j]);
		cout << endl;
	}
	return 0;
}